package cn.etcweb.bait.baitframe.auth.integration.authenticator.password;

import cn.etcweb.bait.baitframe.auth.integration.IntegrationAuthentication;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
import org.springframework.stereotype.Component;

/**
 * 集成验证码登录
 */
@Component
public class VerificationCodeIntegrationAuthenticator  extends UsernamePasswordAuthenticator  {
    private final static String VERIFICATION_CODE_AUTH_TYPE = "vc";
    @Override
    public void prepare(IntegrationAuthentication integrationAuthentication) {
        String vcToken = integrationAuthentication.getAuthParameter("vc_token");
        String vcCode = integrationAuthentication.getAuthParameter("vc_code");
        //验证验证码
        //Result<Boolean> result = vccClient.validate(vcToken, vcCode, null);
        /*if (!result.getData()) {
            throw new OAuth2Exception("验证码错误");
        }*/
    }

    @Override
    public boolean support(IntegrationAuthentication integrationAuthentication) {
        return VERIFICATION_CODE_AUTH_TYPE.equals(integrationAuthentication.getAuthType());
    }
}
